"""
# 定义一个列表
my_list = ["lijianqi","liaogong","software"]
print(my_list)
print(type(my_list))

my_list = ["lijianqi",22,True]
print(my_list)
print(type(my_list))

# 定义一个嵌套列表
my_list = [[1,2,3],[4,5,6]]
print(my_list)
print(type(my_list))

# 通过下标索引去出对应位置的数据
my_list = ["tom","lily","rose"]
# 列表[下标索引]，从前向后从0开始，每次+1，从后向前从-1开始，每次减1
print(my_list[0])
print(my_list[1])
print(my_list[2])
# 错误示范：通过下标索引取数据，不能超出范围
# print(my_list[3])
# 倒序取出
print(my_list[-1])
print(my_list[-2])
print(my_list[-3])

# 取出嵌套列表元素
my_list = [[1,2,3],[4,5,6]]
print(my_list[0][2])
print(my_list[1][1])

# list列表的循环
# 1.while循环
def list_while_func():
    my_list = {"lijianqi","liaogong","software"}
    index = 0
    while index < len(my_list):
        element = my_list[index]
        index += 1
    print(f"列表的元素：{element}")



list_while_func()

def list_for_func():
    mylist = [1,2,3,4,5]
    for element in mylist:
        print(f"列表元素：{element}")
list_for_func()
"""
# 数据可视化
def list_test1():
    mylist = [1,2,3,4,5,6,7,8,9,10]
    new_list = []
    index = 0
    while index < len(mylist):
        element = mylist[index]
        if element % 2 ==0:
            new_list.append(element)
        index += 1
    print(f"通过while循环，从列表：{mylist}中取出偶数，组成新列表：{new_list}")

def list_test2():
    mylist = [1,2,3,4,5,6,7,8,9,10]
    new_list = []
    for element in mylist:
        if element % 2 == 0:
            new_list.append(element)
            print(f"通过for循环，从列表：{mylist}中取出偶数，组成新列表：{new_list}")
list_test1()
list_test2()

